#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// 2824. 统计和小于目标的下标对数目
// https://leetcode.cn/problems/count-pairs-whose-sum-is-less-than-target/description/

class Solution {
public:
    int countPairs(vector<int>& nums, int target) {
        int left = 0;
        int right = nums.size() - 1;
        int ans = 0;
        sort(nums.begin(), nums.end());
        while (left < right)
        {
            if(nums[left]  + nums[right] < target){
                ans += right - left;
                left++;
            }else{
                right--;
            }
        }
        return ans;
    }
};

int main()
{
    return 0;
}